A extension method of the file information class that returns a formatted version of the file size. For example: 1 GB or B and it at Max it would have two decimals. Add the following code to the common static class of the same namespace, create a
C language Get file size related operationsDisclaimer: Reference Please specify source http://blog.csdn.net/lg1259156776/DescriptionUsually in the hope that the data from the file will be assigned to an array or a pointer, and then the related data
Fgets (read a string from the file)Related functions: open, fread, fscanf, GETCHeader file include Define the function char * fgets (char * s, int size, file * stream );Function Description: fgets () is used to read characters from the file referred
Open the file with fopen and point the file pointer to the end of the file.
Use ftell to get the current position of the file pointer (that is, the file length ).
Source code:# Include "stdafx. H"# Include # Include
Using namespace STD;
Int main (){
C-based file operations
In ANSI C, the operation of the file is divided into two ways, that is, streaming file operations and I/O file operations, respectively, described below.
One, streaming file operation
The file operations in this way have an
Download source code: Click to download
The source code is as follows:
# Include
Iostream
>
# Include
Io. h
>
# Include
Sys \ Stat. h
>
# Include
Afx. h
>
# Define
_ Afxdll
Using
Namespace
This paper introduces in detail the method of using C # to calculate the disk space occupied by this path according to the path.There is a lot of information on the Internet to get the size of the folder/file. There is very little complete code for
C # obtain the file size, creation time, file information, and attributes of the fileinfo class. Table 09:00:40 | category: C # | report | font size subscription openfiledialog1 = new openfiledig1 (); if (openfiledialog1.showdialog () = dialogresult.
1.fseek
Function Prototypes:
Copy Code code as follows:
int fseek (FILE * stream, long int offset, int origin);
Parameter description: Stream, file stream pointer, offest, offset, Orgin, original (beginning position). The
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.